package user_center.role.controller;

import cwb.consts.RequestPrefix;
import cwb.dto.ResultData;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import user_center.role.service.SystemRoleServiceImpl;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Ezio.Auditore
 * Date: 2022-07-20
 * Time: 11:14
 *
 * @author Ezio.Auditore
 */
@RestController
@RequestMapping(RequestPrefix.API + "/system/role")
@Api(value = "系统角色", tags = "系统角色", description = "系统角色")
public class SystemRoleController {

    @Autowired
    private SystemRoleServiceImpl systemRoleService;

    /**
     * 查看角色详情
     *
     * @param roleId
     * @return
     */
    @GetMapping("/detail")
    public ResultData detail(Integer roleId) {
        return ResultData.buildSucess(systemRoleService.getById(roleId));
    }

    /**
     * 角色列表
     *
     * @return
     */
    @GetMapping("/list")
    public ResultData list() {
        return ResultData.buildSucess(systemRoleService.list());
    }

    /**
     * 获取用户拥有的角色列表
     *
     * @param userId
     * @return
     */
    @GetMapping("/getUserRoleList")
    public ResultData getUserRoleList(Integer userId) {
        return ResultData.buildSucess(systemRoleService.getUserRoleList(userId));
    }

}
